package top.raoqq.sky.web.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import top.raoqq.sky.dto.MenuTreeDTO;
import top.raoqq.sky.entity.sql.Menu;
import top.raoqq.sky.service.MenuService;
import top.raoqq.sky.vo.Result;

import java.util.List;


/**
 * @author 饶奇奇
 * @date 2023/8/16
 */
@Api(tags = "菜单管理")
@RestController
@RequiredArgsConstructor
@RequestMapping("/menu")
public class MenuController {

    private final MenuService menuService;

    /**
     *  获取树形结构的菜单,只包含id和菜单名
     */
    private static final String MENU_TREE = "/listMenuTree";

    /**
     * 获取所有菜单树形结构
     */
    private static final String LIST_MENU_TREE = "/listMenu";



    @GetMapping(MENU_TREE)
    @ApiOperation("获取树形结构菜单")
    public Result<List<MenuTreeDTO>> listMenuTree() {
        List<MenuTreeDTO> menuTreeDTOList = menuService.listMenuTree();
        return Result.success(menuTreeDTOList);
    }

    @GetMapping(LIST_MENU_TREE)
    public Result<List<Menu>> listMenu() {
        List<Menu> menuList = menuService.listMenu();
        return Result.success(menuList);
    }



}
